// import time from './time'
export default {
  install(app, option = {}) {
    // app.directive('time',time)
    // 中横线转驼峰
    const camelCase = function (s) {
      return s.replace(/-\w/g, function (x) {
        return x.slice(1).toUpperCase();
      });
    };
    const allDirs = require.context("@/directive/", false, /\.js$/);
    const resComponents = {};
    allDirs.keys().forEach((comName) => {
      let name = camelCase(comName);
      const comp = allDirs(comName);
      if (!comp.default.install) {
        resComponents[name.replace(/^\.\/(.*)\.\w+$/, "$1")] = comp.default;
      }

      for (const key in resComponents) {
        if (Object.hasOwnProperty.call(resComponents, key)) {
          const element = resComponents[key];
          app.directive(key, element);
        }
      }
      // console.log(app);
    });
  },
};
